<template>
  <el-drawer
    title="详情"
    :visible.sync="visible"
    :wrapperClosable="false"
    size="800px"
    append-to-body
    class="jsbos-common-drawer"
  >
    <div class="jsbos-flex-main">
      <div class="dynamicForm dynamicDetail">
        <el-form
          v-loading="loading"
          ref="elForm"
          :model="dataForm"
          size="small"
          label-width="100px"
          label-position="right"
        >
          <template v-if="!loading">
            <el-col :span="24">
              <el-form-item label="证书来源" prop="resourceType">
                <p>
                  {{ dataForm.resourceType | dynamicText(resourceTypeOptions) }}
                </p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="证书名称" prop="name">
                <p>{{ dataForm.name }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="证书编号" prop="code">
                <p>{{ dataForm.code }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="证书类别" prop="category">
                <p>{{ dataForm.category }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="证书等级" prop="grade">
                <p>{{ dataForm.grade }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="证书所属人" prop="certUserId">
                <p>{{ dataForm.certUserId }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="发证单位" prop="certBy">
                <p>{{ dataForm.certBy }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="证书扫描件" prop="cover">
                <UploadFz
                  v-model="dataForm.cover"
                  disabled
                  detailed
                  :showTip="true"
                  :fileSize="5"
                  sizeUnit="MB"
                  :limit="5"
                  buttonText="点击上传"
                >
                </UploadFz>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="有效期" prop="expiredType">
                <p>
                  {{ dataForm.expiredType | dynamicText(expiredTypeOptions) }}
                </p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="过期日期" prop="expiredDate">
                <p>{{ jsbos.dateFormat(dataForm.expiredDate) }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="复审日期" prop="reviewDate">
                <p>{{ jsbos.dateFormat(dataForm.reviewDate) }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="证书介绍" prop="description">
                <p>{{ dataForm.description }}</p>
              </el-form-item>
            </el-col>
          </template>
        </el-form>
      </div>
      <div class="drawer-footer">
        <el-button @click="visible = false"> 取 消 </el-button>
      </div>
    </div>
  </el-drawer>
</template>
<script>
import request from "@/utils/request";
import PrintBrowse from "@/components/print-browse";
import jsbos from "@/utils/jsbos";

export default {
  components: { PrintBrowse },
  props: [],
  data() {
    return {
      visible: false,
      loading: false,
      printBrowseVisible: false,
      printId: "",
      dataForm: {
        id: "",
        resourceType: "",
        resourceId: "",
        certId: "",
        name: "",
        code: "",
        category: "",
        grade: "",
        certUserId: "",
        certBy: "",
        idCard: "",
        contentJson: "",
        cover: [],
        expiredType: "1",
        expiredDate: "",
        reviewDate: "",
        description: "",
        creatorUserId: "",
        creatorTime: "",
      },
      resourceTypeOptions: [
        { fullName: "课程", id: "10" },
        { fullName: "考试", id: "20" },
        {
          fullName: "专题",
          id: "30",
        },
        { fullName: "项目管理", id: "40" },
        { fullName: "新人培训", id: "50" },
        {
          fullName: "学习地图",
          id: "60",
        },
        { fullName: "资质证书", id: "90" },
      ],
      expiredTypeOptions: [
        { fullName: "永久有效", id: "1" },
        { fullName: "有效周期", id: "0" },
      ],
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    dataInfo(dataAll) {
      let _dataAll = dataAll;
      _dataAll.cover = _dataAll.cover ? JSON.parse(_dataAll.cover) : [];
      this.dataForm = _dataAll;
    },

    init(id) {
      this.dataForm.id = id || 0;
      this.visible = true;
      this.$nextTick(() => {
        if (this.dataForm.id) {
          this.loading = true;
          request({
            url: "/api/course/TemsCertUser/detail/" + this.dataForm.id,
            method: "get",
          }).then((res) => {
            this.dataInfo(res.data);
            this.loading = false;
          });
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.jsbos-row-style {
  padding: 10px 10px 10px 0;

  > .el-row {
    margin: 0 !important;
    padding: 0 16px;
  }

  .el-row:nth-child(0) {
    padding: 0px !important;
  }

  > .el-col {
    padding: 0px !important;

    .el-form-item {
      margin-bottom: -1px !important;
      margin-right: -1px;
      border: 1px solid var(--border-4) !important;
      background-color: var(--light-blue) !important;
    }

    .el-form-item__label {
      line-height: 38px;
      height: 100%;
    }

    .el-form-item__content {
      line-height: 38px;
      padding-left: 20px;
      background-color: var(--white) !important;
      border-left: 1px solid var(--border-4) !important;
    }
  }
}
</style>
